//
//  XZLotteryCell.m
//  生活小助手
//
//  Created by MAC－ME on 14-8-7.
//  Copyright (c) 2014年 lxz. All rights reserved.
//

#define labelW kScreenWidth / 5

#import "XZLotteryCell.h"
#import "XZLottery.h"

@interface XZLotteryCell ()
 /*彩票类型*/
@property (weak,nonatomic) UILabel  *lotteryLabel;
/*期号*/
@property (weak,nonatomic) UILabel  *noLabel;
/*开奖日期*/
@property (weak,nonatomic) UILabel  *timeLabel;
/*开奖号码*/
@property (weak,nonatomic) UILabel  *numsLabel;
 /*本期销量*/
@property (weak,nonatomic) UILabel  *salesLabel;

@end

@implementation XZLotteryCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        UILabel *lottery = [self setupLabelWithText:nil];
        lottery.x= 0;
        lottery.width = 70;
        self.lotteryLabel = lottery;
        
        /*期号*/
         UILabel *no = [self setupLabelWithText:nil];
        no.x= CGRectGetMaxX(lottery.frame);
        no.width = 40;
        self.noLabel = no;
        
        /*开奖日期*/
         UILabel *time = [self setupLabelWithText:nil];
        time.x = CGRectGetMaxX(no.frame);
 
        time.width = 70;
        self.timeLabel = time;
 
        /*开奖号码*/
        UILabel *nums = [self setupLabelWithText:nil];
        nums.x = CGRectGetMaxX(time.frame);
 
        nums.width = 70;
        self.numsLabel = nums;
        
        /*本期销量*/
        UILabel *sales = [self setupLabelWithText:nil];
        sales.x = CGRectGetMaxX(nums.frame);
        sales.width = 70;
        self.salesLabel = sales;
        
       
    }
    return self;
}
-  (void)setLottery:(XZLottery *)lottery
{
    _lottery = lottery;
    
    self.lotteryLabel.text =  lottery.lottery;
    self.noLabel.text = lottery.lottery_no;
    self.numsLabel.text = lottery.lottery_nums;
    self.timeLabel.text = lottery.lottery_time;
    if ([lottery.lottery_sales  isEqual: @""]) {
        self.salesLabel.text = @"0";
    }
    else
    {
    self.salesLabel.text = lottery.lottery_sales;
    }
    
}
- (UILabel *)setupLabelWithText:(NSString *)text
{
    UILabel *label = [[UILabel alloc]init];
    label.y = 0;
    label.font = [UIFont systemFontOfSize:13];
    [self addSubview:label];
    label.layer.borderWidth = .5f;
    label.layer.borderColor = ([UIColor orangeColor].CGColor);
    label.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:label];
    label.numberOfLines = 5;
    label.text = text;
    return label;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    for (UILabel *label in self.contentView.subviews) {
        label.height= self.height;
    }
}
@end
